package priv.mill.service;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import priv.mill.entry.CarInfo;
import priv.mill.util.HandlerSet;
import priv.mill.util.JDBCUtil;
import priv.mill.util.MysqlkMessages;

public class CarInfoService {
	
	public List<CarInfo> findByPage(int pageNum) throws SQLException {
		String sql = "select * from car_info limit ?,10";
		return JDBCUtil.query(sql, new HandlerSet<CarInfo>() {

			@Override
			public CarInfo handler(ResultSet rs) throws SQLException {
				CarInfo carInfo = new CarInfo();
				carInfo.setId(rs.getInt("id"));
				carInfo.setPrice(rs.getDouble("price"));
				carInfo.setPinpai(rs.getString("pinpai"));
				carInfo.setLocalMain(rs.getString("local_main"));
				return carInfo;
			}
		}, pageNum);
	}

}
